package com.ruoyi.web.controller.ufox;

import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.ufox.domain.BisConnectionLog;
import com.ruoyi.ufox.service.IBisConnectionLogService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.core.page.TableDataInfo;
import java.util.List;
/**
 * 连接日志Controller
 * 
 * @author ufoxs
 * @date 2022-08-16
 */
@RestController
@RequestMapping("/bussiness/connectLog")
public class BisConnectionLogController extends BaseController
{
    @Autowired
    private IBisConnectionLogService bisConnectionLogService;

    /**
     * 查询连接日志列表
     */
    @PreAuthorize("@ss.hasPermi('bussiness:connectLog:list')")
    @GetMapping("/list")
    public TableDataInfo list(BisConnectionLog bisConnectionLog)
    {
        startPage();
        List<BisConnectionLog> list = bisConnectionLogService.selectBisConnectionLogList(bisConnectionLog);
        return getDataTable(list);
    }

    /**
     * 导出连接日志列表
     */
    @PreAuthorize("@ss.hasPermi('bussiness:connectLog:export')")
    @Log(title = "连接日志", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BisConnectionLog bisConnectionLog)
    {
        List<BisConnectionLog> list = bisConnectionLogService.selectBisConnectionLogList(bisConnectionLog);
        ExcelUtil<BisConnectionLog> util = new ExcelUtil<BisConnectionLog>(BisConnectionLog.class);
        util.exportExcel(response, list, "连接日志数据");
    }

    /**
     * 获取连接日志详细信息
     */
    @PreAuthorize("@ss.hasPermi('bussiness:connectLog:query')")
    @GetMapping(value = "/{logId}")
    public AjaxResult getInfo(@PathVariable("logId") Long logId)
    {
        return AjaxResult.success(bisConnectionLogService.selectBisConnectionLogByLogId(logId));
    }

    /**
     * 新增连接日志
     */
    @PreAuthorize("@ss.hasPermi('bussiness:connectLog:add')")
    @Log(title = "连接日志", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BisConnectionLog bisConnectionLog)
    {
        return toAjax(bisConnectionLogService.insertBisConnectionLog(bisConnectionLog));
    }

    /**
     * 修改连接日志
     */
    @PreAuthorize("@ss.hasPermi('bussiness:connectLog:edit')")
    @Log(title = "连接日志", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BisConnectionLog bisConnectionLog)
    {
        return toAjax(bisConnectionLogService.updateBisConnectionLog(bisConnectionLog));
    }

    /**
     * 删除连接日志
     */
    @PreAuthorize("@ss.hasPermi('bussiness:connectLog:remove')")
    @Log(title = "连接日志", businessType = BusinessType.DELETE)
	@DeleteMapping("/{logIds}")
    public AjaxResult remove(@PathVariable Long[] logIds)
    {
        return toAjax(bisConnectionLogService.deleteBisConnectionLogByLogIds(logIds));
    }
}
